package com.talent.jiwen_teacher;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.afollestad.materialdialogs.MaterialDialog;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.entity.LocalMedia;
import com.talent.jiwen_teacher.base.BaseActivity;
import com.talent.jiwen_teacher.http.common.ActivityLifeCycleEvent;
import com.talent.jiwen_teacher.http.common.ApiFactory;
import com.talent.jiwen_teacher.http.common.HttpUtil;
import com.talent.jiwen_teacher.http.common.ProgressSubscriber;
import com.talent.jiwen_teacher.http.result.TeacherAuthInfo;
import com.talent.jiwen_teacher.http.result.TeacherAuthResult;
import com.talent.jiwen_teacher.util.ImageUtil;
import com.talent.jiwen_teacher.util.MaterialDialogUtil;
import com.talent.jiwen_teacher.util.SPUtil;
import com.talent.jiwen_teacher.util.SoftKeyboardUtil;
import com.talent.jiwen_teacher.util.Validators;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;
import rx.Observable;

import static com.talent.jiwen_teacher.UpCertificateActivity.IMG_CERT;
import static com.talent.jiwen_teacher.UpIDCardActivity.IMG_ID_1;
import static com.talent.jiwen_teacher.UpIDCardActivity.IMG_ID_2;
import static com.talent.jiwen_teacher.UpJobEmploymentActivity.IMG_JOB;
import static com.talent.jiwen_teacher.UpStudentCardActivity.IMG_STUDENT;
import static com.talent.jiwen_teacher.UpWithCardActivity.IMG_WITH;
import static com.talent.jiwen_teacher.my.MyFragment.REFRESH_DATA;
import static com.talent.jiwen_teacher.util.Constant.INTERVAL_STR;
import static com.talent.jiwen_teacher.util.Constant.eduList;
import static com.talent.jiwen_teacher.util.Constant.partList;
import static com.talent.jiwen_teacher.util.Constant.subList;

/**
 * Created by qyqx on 2018/8/10.
 * 验证信息
 */

public class CertificationInfoActivity extends BaseActivity {


    @BindView(R.id.img_head)
    ImageView img_head;//头像

    @BindView(R.id.edit_name)
    EditText edit_name;//姓名
    @BindView(R.id.edit_card)
    EditText edit_card;//身份证
    @BindView(R.id.edit_school)
    EditText edit_school;//毕业院校


    @BindView(R.id.txt_sex)
    TextView txt_sex;//性别
    @BindView(R.id.txt_edu)
    TextView txt_edu;//学历
    @BindView(R.id.txt_subject)
    TextView txt_subject;//教学科目
    @BindView(R.id.txt_range)
    TextView txt_range;//授课范围


    @BindView(R.id.txt_up_1)
    TextView txt_up_1;
    @BindView(R.id.txt_up_2)
    TextView txt_up_2;
    @BindView(R.id.txt_up_3)
    TextView txt_up_3;

    @BindView(R.id.txt_up_4)
    TextView txt_up_4;

    @BindView(R.id.school_title)
    TextView school_title;

    @BindView(R.id.ll_teach_year)
    LinearLayout ll_teach_year;//教龄
    @BindView(R.id.edit_teach_years)
    EditText edit_teach_years;

    @BindView(R.id.rl_student)
    RelativeLayout rl_student;//学生证

    @BindView(R.id.rl_qualification)
    RelativeLayout rl_qualification;//教师资格证

    @BindView(R.id.txt_edit)
    TextView txt_edit;//修改信息

    @BindView(R.id.bt_pass)
    Button bt_pass;

    @BindView(R.id.txt_teacher_attention)
    TextView txt_teacher_attention;//教师备注


    @BindView(R.id.rl_job)
    RelativeLayout rl_job;

    @BindView(R.id.txt_up_5)
    TextView txt_up_5;//在职证明

    public static final String TEACHER_IDENTITY="TEACHER_IDENTITY";
    public static final String EDIT_STYLE="EDIT_STYLE";//编辑状态为1 时 更改
    private int identity;

    private List<LocalMedia> pathList = new ArrayList<>();//选择的照片路径
    private List<String> imgList = new ArrayList<>();//压缩后的图片显示路径
    private String headImgUrl;//头像url
    private String userName;
    private int gender=-1;
    private String IDNumber;
    private int educationLevel=-1;
    private String graduatedSchool;
    private int subjectId=-1;
    private int gradePart=-1;
    private String teacherCertificate;
    private String IDCardPicture;
    private String handheldPicture="";

    private String teachYears;//教龄
    private String studentCardUrl;//学生证

    private String jobEmployment;//工作证明

    int editStyle;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_certification_info;
    }

    @Override
    public String titleName() {
        return "认证信息";
    }

    @Override
    protected void initData() {
        identity=getIntent().getIntExtra(TEACHER_IDENTITY,1);

        if(identity==1){
            school_title.setText("毕业院校");
            edit_school.setHint(getString(R.string.cert_school_hint));

            ll_teach_year.setVisibility(View.VISIBLE);
            rl_student.setVisibility(View.GONE);
            rl_qualification.setVisibility(View.VISIBLE);
            if(txt_teacher_attention!=null){
                txt_teacher_attention.setVisibility(View.VISIBLE);
            }
        }else{
            school_title.setText("在读院校");
            edit_school.setHint(getString(R.string.cert_now_hint));
            ll_teach_year.setVisibility(View.GONE);
            rl_student.setVisibility(View.VISIBLE);
            rl_qualification.setVisibility(View.GONE);
//            txt_teacher_attention.setText(View.GONE);
            rl_job.setVisibility(View.GONE);
        }

        editStyle=getIntent().getIntExtra(EDIT_STYLE,0);//为1时为修改状态
        if(editStyle!=0){
            txt_edit.setVisibility(View.VISIBLE);
            getTeacherInfo();
            bt_pass.setVisibility(View.GONE);
            mHeadRightText.setVisibility(View.GONE);
        }else{
            mHeadRightText.setText("跳过");
            mHeadRightText.setTextColor(getResources().getColor(R.color.text_gray_9));
            mHeadRightText.setVisibility(View.VISIBLE);
            txt_edit.setVisibility(View.GONE);
            bt_pass.setVisibility(View.VISIBLE);
        }
    }


    @OnClick({R.id.rl_up_head, R.id.rl_sex,R.id.rl_edu,R.id.rl_subject,R.id.rl_range,R.id.rl_qualification,R.id.rl_crad,R.id.rl_people,R.id.bt_submit,R.id.rl_student,R.id.bt_pass,R.id.rl_job,R.id.text_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_up_head://上传头像
                ImageUtil.pickPhoto(CertificationInfoActivity.this,1,pathList,true);
                break;
            case R.id.rl_sex://性别
                SoftKeyboardUtil.hideSoftKeyboard(CertificationInfoActivity.this);
                showWheelPicker(new ArrayList<String>(Arrays.asList("男","女")),null,CHOOSE_SEX);
                break;
            case R.id.rl_edu://学历
                SoftKeyboardUtil.hideSoftKeyboard(CertificationInfoActivity.this);
                showWheelPicker(new ArrayList<String>(Arrays.asList(eduList)),null,CHOOSE_EDU);
                break;
            case R.id.rl_subject://教学科目
                SoftKeyboardUtil.hideSoftKeyboard(CertificationInfoActivity.this);
                showWheelPicker(new ArrayList<String>(Arrays.asList(subList)),null,CHOOSE_SUBJECT);

                break;
            case R.id.rl_range://授课范围
                SoftKeyboardUtil.hideSoftKeyboard(CertificationInfoActivity.this);
                showWheelPicker(new ArrayList<String>(Arrays.asList(partList)),null,CHOOSE_RANGE);
                break;
            case R.id.rl_qualification://教师资格证
                Intent intent=new Intent(CertificationInfoActivity.this,UpCertificateActivity.class);
                intent.putExtra(IMG_CERT,teacherCertificate);
                startActivityForResult(intent,101);
                break;
            case R.id.rl_crad://身份证
                Intent intent1=new Intent(CertificationInfoActivity.this,UpIDCardActivity.class);
                intent1.putExtra(IMG_ID_1,card_1);
                intent1.putExtra(IMG_ID_2,card_2);
                startActivityForResult(intent1,102);
                break;
            case R.id.rl_people://手持身份证
                Intent intent2=new Intent(CertificationInfoActivity.this,UpWithCardActivity.class);
                intent2.putExtra(IMG_WITH,handheldPicture);
                startActivityForResult(intent2,103);
                break;
            case R.id.rl_student://学生证
                Intent intent3=new Intent(CertificationInfoActivity.this,UpStudentCardActivity.class);
                intent3.putExtra(IMG_STUDENT,studentCardUrl);
                startActivityForResult(intent3,104);
                break;
            case R.id.rl_job://在职证明
                Intent intent4=new Intent(CertificationInfoActivity.this,UpJobEmploymentActivity.class);
                intent4.putExtra(IMG_JOB,jobEmployment);
                startActivityForResult(intent4,105);

                break;
            case R.id.bt_submit://提交
                if(userState==1){//正常
                    showClassDialog();
                }else{
                    certWord();
                }

                break;
            case R.id.bt_pass:
                intentActivity(LoginActivity.class);
                finish();
                break;
            case R.id.text_right:
                intentActivity(LoginActivity.class);
                finish();
                break;
        }
    }

    public void showClassDialog(){

        MaterialDialog.Builder dialog= MaterialDialogUtil.getCommonDialog(CertificationInfoActivity.this, "提交验证", "您的验证已通过，是否重新验证？", "是", "否", new MaterialDialogUtil.OnDialogPoNeClickListener() {
            @Override
            public void onPositive() {
                certWord();
            }

            @Override
            public void onNegative() {

            }
        });

        dialog.show();
    }

    private void certWord(){

        userName=edit_name.getText().toString().trim();
        IDNumber=edit_card.getText().toString().trim();
        graduatedSchool=edit_school.getText().toString().trim();
        teachYears=edit_teach_years.getText().toString().trim();

        if(Validators.isEmpty(headImgUrl)){
            showToast("请上传头像");
            return;
        }else if(headImgUrl.equals("http://education123.oss-cn-hangzhou.aliyuncs.com/9eb228857bf94e1ab6a84180f7c8a634logo_teacher.png")){
            headImgUrl=null;
            showToast("请上传头像");
            return;
        }

        if(Validators.isEmpty(userName)){
            showToast("请填写您的真实姓名");
            return;
        }

        if(gender<=0 || gender==3){
            showToast("请选择您的性别");
            return;
        }

        if(Validators.isEmpty(IDNumber)){
            showToast("请填写您的身份证号");
            return;
        }

        if(educationLevel<=0){
            showToast("请选择您的学历");
            return;
        }


        if(subjectId<=0){
            showToast("请选择您所教学科");
            return;
        }

        if(gradePart<=0){
            showToast("请选择您的授课范围");
            return;
        }

        if(Validators.isEmpty(IDCardPicture)){
            showToast("请上传您的身份证");
            return;
        }

//                if(Validators.isEmpty(handheldPicture)){
//                    showToast("请上传您与身份证的合照");
//                    return;
//                }

        if(identity==1){//老师
            if(Validators.isEmpty(teachYears)){
                showToast("请输入您的教龄");
                return;
            } else if(teachYears.equals("0")){
                showToast("教龄请输入大于0的数字");
                return;
            }

            if(Validators.isEmpty(graduatedSchool)){
                showToast("请输入您的毕业院校");
                return;
            }

            if(Validators.isEmpty(teacherCertificate) && Validators.isEmpty(jobEmployment)){
                showToast("请上传您的教师资格证或者在职证明");
                return;
            }
        }else{

            if(Validators.isEmpty(graduatedSchool)){
                showToast("请输入您所在院校名称");
                return;
            }

            if(Validators.isEmpty(studentCardUrl)){
                showToast("请上传您的学生证");
                return;
            }
        }
        if(editStyle!=0){
            authenticationAgin();
        }else{
            upRegister();
        }

    }

    int userState=0;//用户状态（1：正常 2:未认证 3：未填写个人信息 4：认证失败 9：注销）

    private void getTeacherInfo(){
        Map<String, String> map = new HashMap<>();
        map.put("teacherId", SPUtil.getUserId());

        Observable observable = ApiFactory.getEducationApiSingleton().getTeacherAuthInfo(SPUtil.getToken(),map);
        HttpUtil.getInstance().toSubscribe(observable, new ProgressSubscriber<TeacherAuthResult>(this) {
            @Override
            protected void _onNext(TeacherAuthResult teacherAuthResult) {
                TeacherAuthInfo teacherAuthInfo=teacherAuthResult.teacherAuthInfo;
                if(teacherAuthInfo!=null){

                    userState=teacherAuthInfo.getUserStatus();

                    headImgUrl=teacherAuthInfo.getUserHeadImage();

                    ImageUtil.loadCircleImageWithDefault(mContext,headImgUrl,R.mipmap.img_cert_head,img_head);

                    switch (userState){
                        case 1:
                            txt_edit.setVisibility(View.GONE);
                            break;
                        case 2:
                            txt_edit.setVisibility(View.GONE);
                            break;
                        case 3:
                            txt_edit.setVisibility(View.GONE);
                            break;
                        case 4:
                            //认证失败
                            txt_edit.setVisibility(View.VISIBLE);
                            if(!Validators.isEmpty(teacherAuthInfo.getErrorMessage())){
                                txt_edit.setText("未通过原因："+teacherAuthInfo.getErrorMessage());
                            }else{
                                txt_edit.setText("认证审核未通过，请重新提交信息。");
                            }
                            break;
                    }

                    userName=teacherAuthInfo.getRealName();
                    edit_name.setText(userName);

                    gender=teacherAuthInfo.getGender();
                    if(gender==1){
                        txt_sex.setText("男");
                    }else if(gender==2){
                        txt_sex.setText("女");
                    }

                    IDNumber=teacherAuthInfo.getUserIDNumber();
                    edit_card.setText(IDNumber);

                    educationLevel=teacherAuthInfo.getEducationLevel();
                    if(educationLevel>0){
                        txt_edu.setText(eduList[educationLevel-1]);
                    }

                    gradePart=teacherAuthInfo.getGradePart();
                    if(gradePart>0){
                        txt_range.setText(partList[gradePart-1]);
                    }


                    subjectId=teacherAuthInfo.getSubjectId();
                    if(subjectId>0){
                        txt_subject.setText(subList[subjectId-1]);
                    }


                    graduatedSchool=teacherAuthInfo.getGraduatedSchool();
                    edit_school.setText(graduatedSchool);

                    teachYears=teacherAuthInfo.getTeachAge();
                    if(!Validators.isEmpty(teachYears)){
                        if(!teachYears.equals("0")){
                            edit_teach_years.setText(teachYears);
                        }
                    }

                    teacherCertificate=teacherAuthInfo.getTeacherCertificate();
                    if(identity==1){
                        if(Validators.isEmpty(teacherCertificate)){
                            setTextViewImg(txt_up_1,true);
                        }else{
                            setTextViewImg(txt_up_1,false);
                        }
                    }else{
                        studentCardUrl=teacherAuthInfo.getTeacherCertificate();
                        if(Validators.isEmpty(studentCardUrl)){
                            setTextViewImg(txt_up_4,true);
                        }else{
                            setTextViewImg(txt_up_4,false);
                        }
                    }

                    IDCardPicture=teacherAuthInfo.getIdcardPicture();
                    if(!Validators.isEmpty(IDCardPicture) && IDCardPicture.contains(INTERVAL_STR)){
                        String [] card=IDCardPicture.split(INTERVAL_STR);
                        card_1=card[0];
                        card_2=card[1];
                        if(Validators.isEmpty(IDCardPicture)){
                            setTextViewImg(txt_up_2,true);
                        }else{
                            setTextViewImg(txt_up_2,false);
                        }
                    }else{
                        setTextViewImg(txt_up_2,true);
                    }


                    handheldPicture=teacherAuthInfo.getHandheldPicture();
                    if(Validators.isEmpty(handheldPicture)){
                        setTextViewImg(txt_up_3,true);
                    }else{
                        setTextViewImg(txt_up_3,false);
                    }


                    jobEmployment=teacherAuthInfo.getIncumbencyCertification();
                    if(Validators.isEmpty(jobEmployment)){
                        setTextViewImg(txt_up_5,true);
                    }else{
                        setTextViewImg(txt_up_5,false);
                    }

                }

            }

            @Override
            protected void _onError(String message) {
                showToast(message);
            }
        }, ActivityLifeCycleEvent.DESTROY, lifecycleSubject,true);
    }


    private void authenticationAgin(){
        Map<String, String> map = new HashMap<>();
        map.put("teacherId", SPUtil.getUserId());
        map.put("userHeadImage", headImgUrl);
        map.put("teacherName", userName);
        map.put("gender", ""+gender);
        map.put("IDNumber", IDNumber);
        map.put("educationLevel", ""+educationLevel);
        map.put("graduatedSchool", graduatedSchool);
        map.put("subjectId", ""+subjectId);
        map.put("gradePart", ""+gradePart);
        if(identity==1){
            map.put("teacherCertificate",Validators.isEmpty(teacherCertificate) ? "": teacherCertificate);
            map.put("educationYear", teachYears);
            map.put("incumbencyCertification",Validators.isEmpty(jobEmployment) ? "": jobEmployment);
        }else{
            map.put("teacherCertificate",studentCardUrl);
        }
        map.put("IDCardPicture", IDCardPicture);
        map.put("handheldPicture",Validators.isEmpty(handheldPicture) ? "": handheldPicture);
        Observable observable = ApiFactory.getEducationApiSingleton().teacherAuthenticationAgin(SPUtil.getToken(),map);
        HttpUtil.getInstance().toSubscribe(observable, new ProgressSubscriber<Void>(this) {
            @Override
            protected void _onNext(Void v) {
                EventBus.getDefault().post(REFRESH_DATA);
                showToast("提交成功,请耐心等待审核");
                finish();
            }

            @Override
            protected void _onError(String message) {
                showToast(message);
            }
        }, ActivityLifeCycleEvent.DESTROY, lifecycleSubject,true);
    }




    private void upRegister(){
        Map<String, String> map = new HashMap<>();
        map.put("teacherId", SPUtil.getUserId());
        map.put("userHeadImage", headImgUrl);
        map.put("teacherName", userName);
        map.put("gender", ""+gender);
        map.put("IDNumber", IDNumber);
        map.put("educationLevel", ""+educationLevel);
        map.put("graduatedSchool", graduatedSchool);
        map.put("subjectId", ""+subjectId);
        map.put("gradePart", ""+gradePart);
        if(identity==1){
            map.put("teacherCertificate", Validators.isEmpty(teacherCertificate) ? "": teacherCertificate);
            map.put("educationYear", teachYears);
            map.put("incumbencyCertification",Validators.isEmpty(jobEmployment) ? "": jobEmployment);
        }else{
            map.put("teacherCertificate",studentCardUrl);
        }
        map.put("IDCardPicture", IDCardPicture);
        map.put("handheldPicture", Validators.isEmpty(handheldPicture) ? "": handheldPicture);
        Observable observable = ApiFactory.getEducationApiSingleton().teacherAuthentication(SPUtil.getToken(),map);
        HttpUtil.getInstance().toSubscribe(observable, new ProgressSubscriber<Void>(this) {
            @Override
            protected void _onNext(Void v) {
               intentActivity(LoginActivity.class);
                finish();
            }

            @Override
            protected void _onError(String message) {
                showToast(message);
            }
        }, ActivityLifeCycleEvent.DESTROY, lifecycleSubject,true);
    }


    private static  final  int CHOOSE_SEX=1;
    private static  final  int CHOOSE_EDU=2;
    private static  final  int CHOOSE_SUBJECT=3;
    private static  final  int CHOOSE_RANGE=4;

    /**
     * 滚轮选择
     *
     * @param pickerList
     */
    private void showWheelPicker(final List<String> pickerList, final String str, final int style) {
        List<String> showList = new ArrayList<>();
        int selectPosition = 0;
        for (int i = 0; i < pickerList.size(); i++) {
            showList.add(pickerList.get(i));
            if (null != str){
                if (str.equals( pickerList.get(i))) {
                    selectPosition = i;
                }
            }
        }
        OptionsPickerView pvOptions = new OptionsPickerBuilder(CertificationInfoActivity.this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                switch (style){
                    case CHOOSE_SEX:
                        gender=options1+1;
                        txt_sex.setText(pickerList.get(options1));
                        break;
                    case CHOOSE_EDU:
                        educationLevel=options1+1;
                        txt_edu.setText(pickerList.get(options1));
                        break;
                    case CHOOSE_SUBJECT:
                        subjectId=options1+1;
                        txt_subject.setText(pickerList.get(options1));
                        break;
                    case CHOOSE_RANGE:
                        gradePart=options1+1;
                        txt_range.setText(pickerList.get(options1));
                        break;
                }
            }
        }).setSubmitColor(ContextCompat.getColor(this , R.color.common_app_color))
                .setCancelColor(ContextCompat.getColor(this , R.color.text_gray_6)).build();
        pvOptions.setPicker(showList);

        if (null != str) {
            pvOptions.setSelectOptions(selectPosition);
        }
        pvOptions.show();
    }

    String card_1;
    String card_2;

    @SuppressLint("NewApi")
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case PictureConfig.CHOOSE_REQUEST:
                    pathList.clear();
                    pathList.addAll(PictureSelector.obtainMultipleResult(data));

                    imgList.clear();
                    for (LocalMedia localMedia : pathList) {
                        imgList.add(localMedia.getCompressPath());
                    }
                    if(!Validators.isEmpty(imgList)&& imgList.size()>0){
                        String imgPath=imgList.get(0);

                            if(!Validators.isEmpty(imgPath)){
                                ImageUtil.upLoadSingleImg(imgPath, new ImageUtil.ImgUpLoadListener() {
                                    @Override
                                    public void OnSuccess(String successUrl) {
                                        headImgUrl=successUrl;
                                        ImageUtil.loadCircleImageWithDefault(mContext,successUrl,R.mipmap.img_cert_head,img_head);
                                    }

                                    @Override
                                    public void OnError(String message) {

                                    }

                                    @Override
                                    public void OnListUpSuccess(List<String> successFileList) {

                                    }
                                });
                            }
                    }
                    break;

            }
        }

        switch (resultCode){
            case 1001:
                teacherCertificate=data.getStringExtra(IMG_CERT);
                if(Validators.isEmpty(teacherCertificate)){
                    setTextViewImg(txt_up_1,true);
                }else{
                    setTextViewImg(txt_up_1,false);
                }
                break;

            case 1002:
                card_1=data.getStringExtra(IMG_ID_1);
                card_2=data.getStringExtra(IMG_ID_2);

                if(!Validators.isEmpty(card_1) && !Validators.isEmpty(card_2) ){
                    IDCardPicture=card_1+INTERVAL_STR+card_2;
                }

                if(Validators.isEmpty(IDCardPicture)){
                    setTextViewImg(txt_up_2,true);
                }else{
                    setTextViewImg(txt_up_2,false);
                }

                break;
            case 1003:
                handheldPicture=data.getStringExtra(IMG_WITH);
                if(Validators.isEmpty(handheldPicture)){
                    setTextViewImg(txt_up_3,true);
                }else{
                    setTextViewImg(txt_up_3,false);
                }
                break;

            case 1004:
                studentCardUrl=data.getStringExtra(IMG_STUDENT);
                if(Validators.isEmpty(studentCardUrl)){
                    setTextViewImg(txt_up_4,true);
                }else{
                    setTextViewImg(txt_up_4,false);
                }
                break;

            case 1005:
                jobEmployment=data.getStringExtra(IMG_JOB);
                if(Validators.isEmpty(jobEmployment)){
                    setTextViewImg(txt_up_5,true);
                }else{
                    setTextViewImg(txt_up_5,false);
                }
                break;
        }
    }

    private void setTextViewImg(TextView view,boolean isTure){

        if(isTure){
            Drawable img_ceram=getResources().getDrawable(R.mipmap.img_ceram);
            img_ceram.setBounds(0, 0, img_ceram.getMinimumWidth(), img_ceram.getMinimumHeight());
            view.setCompoundDrawables(img_ceram,null,null,null);
        }else{
            Drawable img_gou=getResources().getDrawable(R.mipmap.up_gou);
            img_gou.setBounds(0, 0, img_gou.getMinimumWidth(), img_gou.getMinimumHeight());
            view.setCompoundDrawables(img_gou,null,null,null);
        }

    }

}
